package chixing.day16.work;

import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;


public class ReadExcel {
    public static void main(String[] args) {
        try {
            XSSFWorkbook xssfWorkbook = new XSSFWorkbook("D:\\a\\student.xlsx");
            int sheetNumber = xssfWorkbook.getNumberOfSheets();
            System.out.println(sheetNumber);
            for (int i = 0; i < sheetNumber; i++) {
                System.out.println("读取第"+(i+1)+"个sheet页");
                XSSFSheet sheet = xssfWorkbook.getSheetAt(i);
                int maxRow = sheet.getLastRowNum();
                for(int row=0;row<=maxRow;row++){
                    int maxRol=sheet.getRow(row).getLastCellNum();
                    System.out.println("第"+row+"行");
                    for(int rol=0;rol<maxRol;rol++){
                        System.out.print(sheet.getRow(row).getCell(rol)+" ");
                    }
                    System.out.println();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
